package cn.xuqiudong.rpc.demo.common.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.time.DateUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.Random;

/**
 * 描述: 测试的model
 * @author Vic.xu
 * @date 2022-03-01 17:20
 */
public class OneModel implements Serializable {

    private int id;

    private String name;

    private int age;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    public static OneModel random(){
        Random random = new Random();
        int id = random.nextInt(100);
        int age = 20 + random.nextInt(10);
        Date date = DateUtils.addYears(new Date(), -age);
        String name = RandomStringUtils.randomAlphanumeric(5);
        return new OneModel(id, name, age, date);
    }

    public OneModel() {
    }

    public OneModel(int id, String name, int age, Date birthday) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.birthday = birthday;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
}
